<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('letter', function (Blueprint $table) {
            $table->id();
            $table->integer('uid')->nullable()->comment('UID');
            $table->string('username',20)->notNull()->comment('寄件人姓名');
            $table->string('email',50)->notNull()->comment('收件邮箱地址');
            $table->tinyInteger('is_public')->default(0)->comment('是否公开 0否 1是');
            $table->string('title',100)->nullable()->comment('邮件标题');
            $table->string('cover')->nullable()->comment('封面');
            $table->longText('content')->nullable()->comment('正文内容');
            $table->integer('views')->default(0)->comment('阅读数');
            $table->integer('likes')->default(0)->comment('点赞数');
            $table->json('common')->nullable()->comment('辅助字段信息');
            $table->tinyInteger('status')->default(0)->comment('状态 0待寄送 1已寄送（寄送成功） 2已阅读 3已取消 4寄送失败');
            $table->dateTime('send_time')->notNull()->comment('发信时间');
            $table->dateTime('delivery_time')->nullable()->comment('发投递时间');
            $table->dateTime('read_time')->nullable()->comment('读信时间');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('letter');
    }
};
